package leetcode.code1593;

import java.util.HashSet;
import java.util.Set;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	int ans;

	public int maxUniqueSplit(String s) {
		ans = -1;
		Set<String> set = new HashSet<>();
		f(s.toCharArray(), 0, set);
		return ans;
	}

	private void f(char[] cs, int start, Set<String> set) {
		if (start == cs.length) {
			ans = Math.max(ans, set.size());
			return;
		}
		for (int i = start; i < cs.length; i++) {
			String cur = new String(cs, start, i - start + 1);
			if (!set.contains(cur)) {
				set.add(cur);
				f(cs, i + 1, set);
				set.remove(cur);
			}
		}
	}

	@Override
	public void debug4() {
		H.compare(2, this.maxUniqueSplit("ccccc"));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}

